#! /usr/bin/env python
# -*- coding:utf-8 -*-


'''请求网页'''
import time

import requests
import  re

#设置agent，不要是python
headers={
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.9 Safari/537.36'
}

response=requests.get("https://www.veryins.com/p/B8NrIwEnnxe",headers=headers)

# print(response.request.headers)

# print(response.text)
# 得到网页信息，准备解析
html=response.text

'''解析网页'''
urls=re.findall('https://s3.veryins.com/image/.*?.jpg.*?=[A-Z0-9]{8}',html)
# 打印图片地址
print(urls)
'''保存图片'''
for url in urls:
    time.sleep(1)
    # 图片的名字
    print(url)
    filename=url.split('=')[-1]+".jpg"
    response = requests.get(url, headers=headers)
    with open(filename,'wb') as f:
            f.write(response.content)
